<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <script>
            var a = 0;

            function foo() {
                console.log(this.a);
            }

            var obj = {
                a: 2,
            };

            foo();

            // ​通过 call()、apply()、bind() 方法把对象绑定到 this 上
            foo.call(obj);
        </script>
    </body>
</html>
